import MOCK from 'mockjs';
let fristTab = [{
    user_id: 1,
    user_name: '张三',
    user_password: '123',
    create_time: '2022-02-08',
  },
  {
    user_id: 2,
    user_name: '李四',
    user_password: '123',
    create_time: '2022-02-09',
  },
  {
    user_id: 3,
    user_name: '王五',
    user_password: '123',
    create_time: '2022-02-10',
  },
  {
    user_id: 4,
    user_name: '王五',
    user_password: '123',
    create_time: '2022-02-08',
  },
  {
    user_id: 5,
    user_name: '王五',
    user_password: '123',
    create_time: '2022-02-08',
  },
  {
    user_id: 6,
    user_name: '王五',
    user_password: '123',
    create_time: '2022-02-08',
  },
  {
    user_id: 7,
    user_name: '王五',
    user_password: '123',
    create_time: '2022-02-08',
  },
  {
    user_id: 8,
    user_name: '王五',
    user_password: '123',
    create_time: '2022-02-08',
  }
];

//获取总数数量
MOCK.mock('http://localhost:8088/home/number', 'get', el => {
  return fristTab.length;
})
//删除单个
MOCK.mock('http://localhost:8088/home/delTab', 'get', el => {
  console.log(el.body)
})
MOCK.mock('http://localhost:8088/home/updateTab', 'get', el => {
  console.log(el.body, 'update')
})
MOCK.mock('http://localhost:8088/home/addTab', 'get', el => {
  console.log(el.body, 'add')
})
MOCK.mock('http://localhost:8088/home/serchTab', 'get', el => {
  let li = JSON.parse(el.body).li;
  let list = [];
  console.log(li, li.id, 'serchTab')
  fristTab.forEach(el => {
    if (el.user_id == li.id) list.push(el);
  });
  let all = {
    list,
    allNumber: list.length,
  }
  return all;
})
